package com.ruoyi.zsyh.controller;

import java.util.List;

import com.ruoyi.common.utils.ShiroUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhPartsApplyRecord;
import com.ruoyi.zsyh.service.IZsyhPartsApplyRecordService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 补助金沟通记录表Controller
 * 
 * @author yuexl
 * @date 2022-08-17
 */
@Controller
@RequestMapping("/zsyh/partsApplyRecord")
public class ZsyhPartsApplyRecordController extends BaseController
{
    private String prefix = "zsyh/partsApplyRecord";

    @Autowired
    private IZsyhPartsApplyRecordService zsyhPartsApplyRecordService;

    @GetMapping()
    public String partsApplyRecord()
    {
        return prefix + "/partsApplyRecord";
    }

    /**
     * 查询补助金沟通记录表列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhPartsApplyRecord zsyhPartsApplyRecord)
    {
        startPage();
        List<ZsyhPartsApplyRecord> list = zsyhPartsApplyRecordService.selectZsyhPartsApplyRecordList(zsyhPartsApplyRecord);
        return getDataTable(list);
    }

    /**
     * 导出补助金沟通记录表列表
     */
    @Log(title = "补助金沟通记录表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhPartsApplyRecord zsyhPartsApplyRecord)
    {
        List<ZsyhPartsApplyRecord> list = zsyhPartsApplyRecordService.selectZsyhPartsApplyRecordList(zsyhPartsApplyRecord);
        ExcelUtil<ZsyhPartsApplyRecord> util = new ExcelUtil<ZsyhPartsApplyRecord>(ZsyhPartsApplyRecord.class);
        return util.exportExcel(list, "补助金沟通记录表数据");
    }

    /**
     * 新增补助金沟通记录表
     */
    @GetMapping("/add")
    public String add(String applyId,ModelMap mmap)

    {
        mmap.put("applyId",applyId);
        return prefix + "/add";
    }

    /**
     * 新增保存补助金沟通记录表
     */
    @Log(title = "补助金沟通记录表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhPartsApplyRecord zsyhPartsApplyRecord)
    {
        zsyhPartsApplyRecord.setCreateName(ShiroUtils.getSysUser().getUserName());
        return toAjax(zsyhPartsApplyRecordService.insertZsyhPartsApplyRecord(zsyhPartsApplyRecord));
    }

    /**
     * 修改补助金沟通记录表
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhPartsApplyRecord zsyhPartsApplyRecord = zsyhPartsApplyRecordService.selectZsyhPartsApplyRecordById(id);
        mmap.put("zsyhPartsApplyRecord", zsyhPartsApplyRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存补助金沟通记录表
     */
    @Log(title = "补助金沟通记录表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhPartsApplyRecord zsyhPartsApplyRecord)
    {
        return toAjax(zsyhPartsApplyRecordService.updateZsyhPartsApplyRecord(zsyhPartsApplyRecord));
    }

    /**
     * 删除补助金沟通记录表
     */
    @Log(title = "补助金沟通记录表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhPartsApplyRecordService.deleteZsyhPartsApplyRecordByIds(ids));
    }
}
